﻿using System;

namespace Database.Core.Exceptions
{
  /// <summary>
  /// Exception indicating a problem during entity population.
  /// </summary>
  [Serializable]
  public class PopulationException : Exception
  {
    private string _propertyName;
    private Type _propertyType;
    private string _columnName;
    private Type _columnType;
    private object _value;

    /// <summary>
    /// Gets or sets the name of the property.
    /// </summary>
    /// <value>The name of the property.</value>
    public string PropertyName
    {
      get { return _propertyName; ; }
      set { _propertyName = value; }
    }

    /// <summary>
    /// Gets or sets the type of the property.
    /// </summary>
    /// <value>The type of the property.</value>
    public Type PropertyType
    {
      get { return _propertyType; }
      set { _propertyType = value; }
    }

    /// <summary>
    /// Gets or sets the name of the column.
    /// </summary>
    /// <value>The name of the column.</value>
    public string ColumnName
    {
      get { return _columnName; }
      set { _columnName = value; }
    }

    /// <summary>
    /// Gets or sets the type of the column.
    /// </summary>
    /// <value>The type of the column.</value>
    public Type ColumnType
    {
      get { return _columnType; }
      set { _columnType = value; }
    }

    /// <summary>
    /// Gets or sets the value.
    /// </summary>
    /// <value>The value.</value>
    public object Value
    {
      get { return _value; }
      set { _value = value; }
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="PopulationException"/> class.
    /// </summary>
    public PopulationException()
    { }

    /// <summary>
    /// Initializes a new instance of the <see cref="PopulationException"/> class.
    /// </summary>
    /// <param name="propertyName">Name of the property.</param>
    /// <param name="propertyType">Type of the property.</param>
    /// <param name="columnName">Name of the column.</param>
    /// <param name="columnType">Type of the column.</param>
    /// <param name="value">The value.</param>
    /// <param name="message">The exception message.</param>
    /// <param name="innerException">The inner exception.</param>
    public PopulationException(string propertyName, Type propertyType, string columnName, Type columnType, object value, string message, Exception innerException)
      : base(message, innerException)
    {
      _propertyName = propertyName;
      _propertyType = propertyType;
      _columnName = columnName;
      _columnType = columnType;
      _value = value;
    }
  }
}
